// 自定义线
import {CurvedEdge, CurvedEdgeModel} from '@logicflow/extension'
import LogicFlow from "@logicflow/core/lib/LogicFlow";
import {FlowNodeTypeEnum} from "@/enums/FlowNodeTypeEnum";

class myCurvedEdge extends CurvedEdge {
}

class myCurvedEdgeModel extends CurvedEdgeModel {
    initEdgeData(data: LogicFlow.EdgeConfig) {
        super.initEdgeData(data)
        this.radius = 5
        // 不允许文本被编辑
        this.text.editable = false
    }

    getEdgeStyle() {
        const style = super.getEdgeStyle()
        style.strokeWidth = 3
        return style
    }

    setAttributes() {
        this.isAnimation = true
    }

    getEdgeAnimationStyle() {
        const style = super.getEdgeAnimationStyle()
        style.strokeDasharray = '15 5'
        style.animationDuration = '20s'
        style.stroke = '#6692CC'
        return style
    }
}

// 注册组件
export function register(lf: LogicFlow) {
    lf.register({
        type: FlowNodeTypeEnum.FLOW_EDGE,
        view: myCurvedEdge,
        model: myCurvedEdgeModel,
    })
}